package com.cleaningcloud.cld.mapper;

import com.cleaningcloud.cld.domain.CldWorkplanSubmit;
import com.cleaningcloud.cld.domain.vo.CldWorkplanSubmitVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

/**
 * 工作计划提交明细Mapper接口
 *
 * @author cleaningcloud
 * @date 2025-01-08
 */
public interface CldWorkplanSubmitMapper {

    /**
     * 查询工作计划提交明细
     *
     * @param workSubmitId 工作计划提交明细主键
     * @return 工作计划提交明细
     */
    CldWorkplanSubmit selectCldWorkplanSubmitByWorkSubmitId(Long workSubmitId);

    /**
     * 查询工作计划提交明细列表
     *
     * @param cldWorkplanSubmit 工作计划提交明细
     * @return 工作计划提交明细集合
     */
    List<CldWorkplanSubmit> selectCldWorkplanSubmitList(CldWorkplanSubmit cldWorkplanSubmit);

    /**
     * 新增工作计划提交明细
     *
     * @param cldWorkplanSubmit 工作计划提交明细
     * @return 结果
     */
    int insertCldWorkplanSubmit(CldWorkplanSubmit cldWorkplanSubmit);

    /**
     * 修改工作计划提交明细
     *
     * @param cldWorkplanSubmit 工作计划提交明细
     * @return 结果
     */
    int updateCldWorkplanSubmit(CldWorkplanSubmit cldWorkplanSubmit);

    /**
     * 删除工作计划提交明细
     *
     * @param workSubmitId 工作计划提交明细主键
     * @return 结果
     */
    int deleteCldWorkplanSubmitByWorkSubmitId(Long workSubmitId);

    /**
     * 批量删除工作计划提交明细
     *
     * @param workSubmitIds 需要删除的数据主键集合
     * @return 结果
     */
    int deleteCldWorkplanSubmitByWorkSubmitIds(Long[] workSubmitIds);

    /**
     * 批量新增工作计划提交
     *
     * @param list
     */
    void batchInsertWorkplanSubmit(@Param("list") List<CldWorkplanSubmit> list);

    /**
     * 修改昨天工作计划待审核的
     *
     * @param yesterday
     */
    @Update("update cld_workplan_submit set approval_status = 3 where  date_format( submit_time,'%Y%m%d') = date_format(#{yesterday},'%Y%m%d') and approval_status = 1")
    void batchAutomaticConfirmTask(Date yesterday);
}
